import { Asset, assetManager } from "cc";

export function loadAysnc<T extends Asset>(bundleUrl:string,url:string){
    return new Promise<T>((resolve,reject)=>{
        assetManager.loadBundle(bundleUrl,(error,bundle)=>{
            if(error){
                console.error(error);
                reject();
                return;
            }
            bundle.load(url,(error,data)=>{
                if(error){
                    console.error(error);
                    reject();
                    return;
                }
                resolve(data as T);  
            });
        });
    });
}